import React, { useEffect, useState } from 'react'
import api from "../../../api"
import OrderListView from "../OrderListView"

export default function OrderList ({ user }) {

  const [orderList, setOrderList] = useState([])

  useEffect(() => {
    api.order({ user }).then(res => {
      // console.log(res.data);
      if (res.data.status === 200) {
        setOrderList(res.data.result)
      }
    }).catch(error => {
      console.log(error);
    })
  }, [])


  return (
    <div>
      <OrderListView data={orderList} />
    </div>
  )
}
